<!-- #INCLUDE File="lib.asp" -->

<?php
' never get this page from cache
Response.ExpiresAbsolute=DateAdd("yyyy", 00, Date)

id = request("id")
command = request("command")

select case command
case "" ' edit
	/*
	sql = "select * from vwcontent where schemaid=" & id
	set rs = tmpConnection.execute(sql)

	van = DBStringToFormDate(rs("van"))
	tot = DBStringToFormDate(rs("tot"))
	
	header
	
	response.write "<h2>" & rs("titel") & "</h2>"
	response.write "<strong>Uitzendschema</strong><hr>"
	
	%>
	<script language="JavaScript" src="script/calendar.js"></script>
	
	<table><form action="schema.asp?command=save&id=<%=id%>&new=<%=request("new")%>" method="post" name="editForm" id="frmSchema">
		<tr><td>Vanaf d.d.</td><td><input onClick="setDateField(document.editForm.van); top.newWin = window.open('calendar.html', 'cal', 'dependent=yes, width=210, height=230, top=180, left=400, screenX=200, screenY=300, titlebar=yes'); top.newWin.focus();" name="van" readonly type="Text" size="10" value="<%=van%>">
								<A HREF="javascript:doNothing()" onClick="setDateField(document.editForm.van); top.newWin = window.open('calendar.html', 'cal', 'dependent=yes, width=210, height=230, top=180, left=400, screenX=200, screenY=300, titlebar=yes'); top.newWin.focus();"><IMG SRC="sysimages/calendar.gif" BORDER=0><font color="#000000">kies datum</font></A>&nbsp;|&nbsp;
								<A HREF="javascript:doNothing()" onClick="document.editForm.van.value = '';"><IMG SRC="sysimages/calendar.gif" BORDER=0><font color="#000000">geen datum</font></A></td></tr>

		<tr><td>Tot en met d.d.</td><td><input onClick="setDateField(document.editForm.tot); top.newWin = window.open('calendar.html', 'cal', 'dependent=yes, width=210, height=230, top=180, left=400, screenX=200, screenY=300, titlebar=yes'); top.newWin.focus();" name="tot" readonly type="Text" size="10" value="<%=tot%>">
								<A HREF="javascript:doNothing()" onClick="setDateField(document.editForm.tot); top.newWin = window.open('calendar.html', 'cal', 'dependent=yes, width=210, height=230, top=180, left=400, screenX=200, screenY=300, titlebar=yes'); top.newWin.focus();"><IMG SRC="sysimages/calendar.gif" BORDER=0><font color="#000000">kies datum</font></A>&nbsp;|&nbsp;
								<A HREF="javascript:doNothing()" onClick="document.editForm.tot.value = '';"><IMG SRC="sysimages/calendar.gif" BORDER=0><font color="#000000">geen datum</font></A></td></tr>

		<tr><td colspan="2"><input type="checkbox" name="ma" <% if rs("ma") then response.write "checked" %>> maandag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="di" <% if rs("di") then response.write "checked" %>> dinsdag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="wo" <% if rs("wo") then response.write "checked" %>> woensdag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="do" <% if rs("do") then response.write "checked" %>> donderdag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="vr" <% if rs("vr") then response.write "checked" %>> vrijdag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="za" <% if rs("za") then response.write "checked" %>> zaterdag</td></tr>
		<tr><td colspan="2"><input type="checkbox" name="zo" <% if rs("zo") then response.write "checked" %>> zondag</td></tr>
		
		<tr><td colspan="2" align="right"><input type="submit" value="Bewaar"> <input type="button" onclick="window.close();" value="Annuleer"></td></tr>
	</form></table>
	<%

	footer
	*/
case "save"
/*
	van = formDateToDBString(request.form("van"))
	tot = formDateToDBString(request.form("tot"))
	week = array("ma", "di", "wo", "do", "vr", "za", "zo")
	sql = "update schema set van = '" & van &"', "
	sql = sql & "tot = '" & tot & "', "
	for each dag in week
		sql = sql & dag & " = " & formBoolToQuery(request.form(dag)) 
		if dag <> week(ubound(week)) then sql = sql & ", "
	next
	sql = sql & " where schemaid = " & id
	tmpConnection.execute(sql)
	
	%><SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
      <!--
	  <% if request("new") = "true" then response.write "window.opener.document.location.reload();" %>
      window.close();
      //-->
</SCRIPT><%
*/
case "new"
/*
	' id = the id of the article
	
	' try if the schema exists
	sql = "select * from schema where artikel = " & id
	set rs = tmpConnection.execute(sql)
	
	if rs.eof then
		' insert new schema
		todayString = formDateToDBString( day(now()) & "/" & month(now()) & "/" & year(now()) )
		sql = "insert into schema (artikel, van, ma, di, wo, do, vr, za, zo) values (" & id & ", '" & todayString & "',1,1,1,1,1,1,1)"
		tmpConnection.execute(sql)
		
		' read the inserted record
		sql = "select * from schema where artikel = " & id
		set rs = tmpConnection.execute(sql)
	end if
	
	schemaid = rs("schemaid")
	response.redirect "schema.asp?id=" & schemaid & "&new=true"
*/	
case "delschema"
	sql = "delete from schema where schemaid = " & id
	tmpConnection.execute(sql)
	response.redirect "editor.asp?command=editpage&position=" & request("position") & "&program=" & request("program")
case else
end select



?>